package com.wlm.controller;

import com.wlm.pojo.ItemCat;
import com.wlm.service.ItemCatService;
import com.wlm.vo.EasyUITree;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/item/cat")
public class ItemCatController {

    @Resource
    private ItemCatService itemCatService;

    @RequestMapping("/queryItemName")
    public String findItemCatById(Long itemCatId) {
        ItemCat itemCat = itemCatService.findItemCatById(itemCatId);
        return itemCat.getName();
    }

    @RequestMapping("/list")
    public List<EasyUITree> findItemCatByParentId(@RequestParam(value = "id", defaultValue = "0") Long parentId) {
        return itemCatService.findEasyUITree(parentId);
    }

}
